package com.lotusfall.impl;

import com.github.pagehelper.PageInfo;
import com.lotusfall.AdService;
import com.lotusfall.mapper.AdServiceMapper;
import com.lotusfall.pojo.Ad;
import com.lotusfall.pojo.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdServiceImpl implements AdService {
    @Autowired
    private AdServiceMapper adServiceMapper;
    @Override
    public PageInfo<Ad> queryAdList(Ad ad, Integer page, Integer pageSize) {
        List<Ad> ads = adServiceMapper.selectByType(ad.getType());
        PageInfo<Ad> adPageInfo = new PageInfo<Ad>(ads,pageSize);
        System.out.println(adPageInfo);
        return adPageInfo;
    }

    @Override
    public PageInfo<Comment> queryCommentList(Integer page, Integer pageSize) {
        List<Comment> comments = this.adServiceMapper.selectAllComments();
        PageInfo<Comment> commentPageInfo = new PageInfo<Comment>(comments,pageSize);
        return commentPageInfo;
    }
}
